<% content_for :css do %>
  <%= stylesheet_link_tag 'applications_index','projects_index' %>
<% end %>
<% content_for :title do %>所有的项目<% end %>
<div id='projects' class="grid_15 models projects">
  <div class="grid_15 head alpha omega">
    <div class="title">
      所有的项目<small>(共<%= @projects.size %>组)</small>
    </div>
  </div>
  <div class="grid_15 alpha">
    <div class="grid_15 alpha all_models all_projects">       
      <% if flash[:success].present? %>
      <div id='success' class="grid_15">
        <div><%= flash[:success] %></div>
      </div>         
      <% end %>
      <div class="grid_15 alpha top">
        <div class="right">   
          <b>查询：</b>
          <%= select_tag 'group_id',options_for_select([ ['所有分组','']]) + options_from_collection_for_select(Enterprise.all, 'id', 'name',params[:enterprise_id]), :id => :enterprise_id %>
          <script type="text/javascript">
            $('#enterprise_id').change(function(){
              // console_debug($(this).val());
              window.location.href = "<%= projects_url %>?enterprise_id=" + $(this).val();
            })
          </script>       
          <div class='cruds'>
            <div>
              <%= link_to '增加', new_project_url, :class => 'crud new', :title => '增加一名新员工' if current_user.is_admin? %>
            </div>
          </div>
        </div>
      </div>
      <% if @projects.empty? %>
        <div class="grid_15 no_model no_project ">无项目</div>
      <% end %>
      <% @projects.each do |project| %>
      <div class='grid_15 alpha omega model project <%= cycle '','h' %>'>
        <div class='grid_2 alpha logo'>          
          <%= image_tag "projects/48x48.png", :size => '50x50', :class => "logo" %>
        </div>
        <div class='grid_9 detail'>
          <div class='name'>
            <%= link_to project.name, project_url(project), :title => project.name %>
          </div> 
          <div class='enterprise'>
            <%= project.enterprise.name %>
          </div>
          <div class='address'>
            <%= project.address %>
          </div>   
          <div class='remark'>
            <%= project.remark %>
          </div>
        </div>
        <% if current_user.is_admin? %>
        <div class='grid_2 omega tools'>
          <%= link_to "编辑资料",edit_project_url(project),  
              :method => :get,:title => '编辑该项目资料', :class => 'tool' %>
          <%= link_to "删除项目", project_url(project),
              :method => :delete,
              :title => '删除该项目',
              :class => 'tool',
              :confirm => "确定要删除该项目吗？"%>
        </div>
        <% end %>        
      </div>
      <% end %>
    </div>
  </div>
</div>  